@extends('admin/layout')
@push('style')
    <link rel="stylesheet" href="/admin/assets/css/login.css?v3">
@endpush
@section('body')
    <div class="login-wrapper layui-anim layui-anim-scale layui-hide">
        <form class="layui-form">
            <h2>用户注册</h2>
            <div style="color: red;padding-bottom: 5px;">请使用未在官网注册过的邮箱注册大客户账号</div>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-username"></i>
                <input class="layui-input" name="email" placeholder="请输入邮箱"
                       autocomplete="off"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-password"></i>
                <input class="layui-input" name="password" placeholder="@lang('system.login.tips.password')"
                       type="password"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
            <div class="layui-form-item layui-input-icon-group">
                <i class="layui-icon layui-icon-password"></i>
                <input class="layui-input" name="password_confirmation" placeholder="再次输入密码"
                       type="password"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
            <div class="layui-form-item layui-input-icon-group login-captcha-group">
                <i class="layui-icon layui-icon-auz"></i>
                <input class="layui-input" id="txtCaptcha" name="captcha" placeholder="@lang('system.login.tips.captcha')"
                       autocomplete="off"
                       lay-verType="tips" lay-verify="required" required/>
                <img class="login-captcha" alt=""/>
            </div>
{{--            <div class="layui-form-item layui-input-icon-group login-captcha-group">--}}
{{--                <i class="layui-icon layui-icon-auz"></i>--}}
{{--                <input class="layui-input" name="captcha" placeholder="请输入邮箱验证码"--}}
{{--                       autocomplete="off"--}}
{{--                       lay-verType="tips" lay-verify="required" required/>--}}
{{--                <div class="login-captcha">--}}
{{--                    <a class="layui-btn layui-btn-fluid" id="btnSend">发送验证码</a>--}}
{{--                </div>--}}
{{--            </div>--}}
            <div class="layui-form-item">
                <a href="{{admin_url('public/login')}}" class="layui-link pull-right">登录账号</a>
{{--                <a href="{{admin_url('public/findPass')}}" class="layui-link pull-right" style="padding-right: 10px;">找回密码</a>--}}
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-filter="loginSubmit"
                        lay-submit>注册
                </button>
            </div>

            <!--        <div class="layui-form-item login-oauth-group text-center">-->
            <!--            <a href="javascript:;"><i class="layui-icon layui-icon-login-qq" style="color:#3492ed;"></i></a>&emsp;-->
            <!--            <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat" style="color:#4daf29;"></i></a>&emsp;-->
            <!--            <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo" style="color:#CF1900;"></i></a>-->
            <!--        </div>-->
        </form>
    </div>
{{--    <div class="login-copyright">copyright © 2022 {{config('app.name', '')}} all rights reserved.</div>--}}
@stop
@push('script')
    <script>
        if (window !== top) top.location.replace(location.href);
        layui.use(['layer', 'form', 'admin', 'dropdown'], function () {
            var $ = layui.jquery, layer = layui.layer, form = layui.form, captchaUrl = '{{captcha_src()}}';
            $('.login-wrapper').removeClass('layui-hide');
            sessionStorage.clear();
            /* 表单提交 */
            form.on('submit(loginSubmit)', function (obj) {
                SystemUtil.ajax("{{admin_url('public/register')}}")
                    .setData(obj.field)
                    .send(1)
                    .done((res) => {
                        layer.msg(res.msg, {icon: 1, time: 1500}, function () {
                            location.replace("{{admin_url('index')}}");
                        });
                    }).fail(() => {
                    $('img.login-captcha').attr('src', captchaUrl + '?t=' + (new Date).getTime());
                })
                return false;
            });
            /* 图形验证码 */
            $('img.login-captcha').click(function () {
                this.src = captchaUrl + '?t=' + (new Date).getTime();
            }).trigger('click');

            {{--$('#btnSend').click(function () {--}}
            {{--    SystemUtil.ajax("{{admin_url('public/sendRegisterCode')}}")--}}
            {{--        .setData({--}}
            {{--            captcha: $('#txtCaptcha').val(),--}}
            {{--            email: $('[name=email]').val()--}}
            {{--        })--}}
            {{--        .send(3);--}}
            {{--    return false;--}}
            {{--});--}}
            window.changeLang = function (lang) {
                setLang(lang);
                layui.admin.closeAllTabs();
                location.reload();
            }
        });
    </script>
@endpush
